// var i;
// var $eventManager = require("./EventManager");
// var $resKeeper = require("./ResKeeper");
// var $commonUtils = require("./CommonUtils");
// var $evenType = require("./EvenType");
// var $gameDataManager = require("./GameDataManager");
// var p = cc._decorator;
// var h = p.ccclass;
// var f = p.property;
// var g = p.inspector;
// var _ = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.icon = null;
//         t.cost = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
//         this.initYinBi();
//     };
//     t.prototype.addYinBi = function (e, t, o, n) {
//         if (void 0 === t) {
//             t = null;
//         }
//         if (void 0 === n) {
//             n = !0;
//         }
//         $commonUtils.default.showCoin(this.icon.node.convertToWorldSpaceAR(cc.v2()), t, e, "yinbi", n, o);
//     };
//     t.prototype.initYinBi = function () {
//         this.cost.string = $gameDataManager.GameDataMgr.sliderCoin + "";
//     };
//     t.prototype.onDisable = function () {
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
//     };
//     __decorate([f(cc.Sprite)], t.prototype, "icon", void 0);
//     __decorate([f(cc.Label)], t.prototype, "cost", void 0);
//     return __decorate([h], t);
// })($resKeeper.default);
// exports.default = _;


// import CommonUtils from './CommonUtils';
// import { EventMgrInstance } from './EventManager';
// import { EVENT_TYPE } from './EvenType';
// import { GameDataMgr } from './GameDataManager';
// import { LogMgr } from './LogManager';
// import ResKeeper from './ResKeeper';

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: CoinManager
//  */
// @ccclass
// class UI_GameYinBi extends ResKeeper {
//     @property(cc.Sprite)
//     public icon: cc.Sprite = null;

//     @property(cc.Label)
//     public cost: cc.Label = null;

//     /**
//      * 当组件启用时调用，添加事件监听器并初始化银币
//      * 建议方法名: onComponentEnable
//      */
//     onEnable(): void {
//         EventMgrInstance.addEventListener(EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
//         EventMgrInstance.addEventListener(EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
//         this.initYinBi();
//     }

//     /**
//      * 添加银币
//      * @param e - 银币数量
//      * @param t - 目标节点
//      * @param o - 额外参数
//      * @param n - 是否播放动画
//      * 建议方法名: addCoin
//      */
//     addYinBi(e: number, t: cc.Vec2 | null = null, o?: any, n: boolean = true): void {
//         LogMgr.debug("addYinBi", e, t, o, n);
//         CommonUtils.showCoin(this.icon.node.convertToWorldSpaceAR(cc.v2()), t, e, "yinbi", n, o);
//     }

//     /**
//      * 初始化银币
//      * 建议方法名: initializeCoin
//      */
//     initYinBi(): void {
//         this.cost.string = GameDataMgr.sliderCoin + "";
//     }

//     /**
//      * 当组件禁用时调用，移除事件监听器
//      * 建议方法名: onComponentDisable
//      */
//     onDisable(): void {
//         EventMgrInstance.rmEventListener(EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
//         EventMgrInstance.rmEventListener(EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
//     }
// }

// export default UI_GameYinBi;

import CommonUtils from './CommonUtils';
import { EventMgrInstance } from './EventManager';
import { EVENT_TYPE } from './EvenType';
import { GameDataMgr } from './GameDataManager';
import { LogMgr } from './LogManager';
import ResKeeper from './ResKeeper';

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: CoinManager
 */
@ccclass
class ViewGameYinBi extends ResKeeper {
    @property(cc.Sprite)
    public icon: cc.Sprite = null;

    @property(cc.Label)
    public cost: cc.Label = null;

    /**
     * 当组件启用时调用，添加事件监听器并初始化银币
     * 建议方法名: onComponentEnable
     */
    onEnable(): void {
        EventMgrInstance.addListener(EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
        EventMgrInstance.addListener(EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
        this.initYinBi();
    }

    /**
     * 添加银币
     * @param coinAmount - 银币数量
     * @param targetPosition - 目标节点位置
     * @param extraParams - 额外参数
     * @param save - 是否保存数据
     * 建议方法名: addCoin
     */
    addYinBi(coinAmount: number, targetPosition: cc.Vec2 | null = null, extraParams?: any, save: boolean = true): void {
        LogMgr.debug("addYinBi", coinAmount, targetPosition, extraParams, save);
        CommonUtils.showCoinAnimation(this.icon.node.convertToWorldSpaceAR(cc.v2()), targetPosition, coinAmount, "yinbi", save, extraParams);
    }

    /**
     * 初始化银币
     * 建议方法名: initializeCoin
     */
    initYinBi(): void {
        this.cost.string = GameDataMgr.getSilverCoin + "";
    }

    /**
     * 当组件禁用时调用，移除事件监听器
     * 建议方法名: onComponentDisable
     */
    onDisable(): void {
        EventMgrInstance.removeListener(EVENT_TYPE.Game_YinBiValue, this.initYinBi, this);
        EventMgrInstance.removeListener(EVENT_TYPE.Game_Add_YinBi, this.addYinBi, this);
    }
}

export default ViewGameYinBi;